<?xml version='1.0' encoding='UTF-8' ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/template/template.xhtml"
	xmlns:o="http://omnifaces.org/ui"
	xmlns:of="http://omnifaces.org/functions">

	<ui:define name="styleAndScript">
	</ui:define>
	<ui:define name="center_content">
		<p:breadCrumb>
			<p:menuitem value="首页" url="/faces/index.xhtml" />
			<p:menuitem value="用户管理" url="#" />
		</p:breadCrumb>
		<h:form id="main_form" prependId="false">
			<div class="style1">
				<h:panelGrid columns="6"
					columnClasses="column1,column2,column1,column2,column1,column2">
					<h:outputText value="用户编号：" />
					<p:inputText value="#{userBean.queryMap['code']}" />
					<h:outputText value="用户名称：" />
					<p:inputText value="#{userBean.queryMap['name']}" />
					<h:outputText value="用户性别：" />
					<h:selectOneMenu value="#{userBean.queryMap['sex']}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all">
						<f:selectItem itemLabel="#{msgs.select}" itemValue="" />
						<f:selectItem itemLabel="男" itemValue="男" />
						<f:selectItem itemLabel="女" itemValue="女" />
					</h:selectOneMenu>

					<h:outputText value="出生年月：" />
					<p:calendar value="#{userBean.queryMap['startBirth']}"
						pattern="yyyy-MM-dd" locale="cn" navigator="true" />
					<h:outputText value="到：" />
					<p:calendar value="#{userBean.queryMap['endBirth']}"
						pattern="yyyy-MM-dd" locale="cn" navigator="true" />
				</h:panelGrid>
				<div>
					<p:commandButton value="#{msgs.btnQuery}" icon="#{comm.queryClass}"
						action="#{userBean.search}" update=":main_form:user_data_table" 
						disabled="#{!userBean.permission.query}"/>
					<p:commandButton value="#{msgs.btnReset}" icon="#{comm.resetClass}"
						type="reset" />
				</div>
			</div>

			<p:contextMenu for="user_data_table">
				<p:menuitem value="#{msgs.btnQuery}" icon="#{comm.queryClass}"
					oncomplete="user_edit_var.show();" update=":user_edit_dialog"
					disabled="#{!userBean.permission.query}">
					<f:setPropertyActionListener target="#{userBean.model}" value="#{comm.m_q}" />
					<f:setPropertyActionListener target="#{userBean.summary}" value="查询用户信息：" />
					<f:setPropertyActionListener target="#{userBean.instance.validPassword}" 
						value="#{userBean.instance.password}" />
				</p:menuitem>
				<p:menuitem value="#{msgs.btnEdit}" icon="#{comm.editClass}"
					oncomplete="user_edit_var.show();" update=":user_edit_dialog"
					disabled="#{!userBean.permission.modify}">
					<f:setPropertyActionListener target="#{userBean.model}" value="#{comm.m_m}" />
					<f:setPropertyActionListener target="#{userBean.summary}" value="编辑用户信息：" />
					<f:setPropertyActionListener target="#{userBean.instance.validPassword}"
						value="#{userBean.instance.password}" />
				</p:menuitem>
			</p:contextMenu>

			<p:dataTable id="user_data_table" value="#{userBean.lazyData}"
				var="data" paginator="true" rows="10" paginatorPosition="bottom"
				paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
				currentPageReportTemplate="{currentPage}/{totalPages}"
				selectionMode="single" selection="#{userBean.instance}"
				emptyMessage="#{msgs.emptyResult}">
				<f:facet name="header">用户信息列表
					<div
						style="text-align: right; position: relative; margin: -13px -5px 0px 0px; vertical-align: middle">
						<p:commandButton value="#{msgs.btnNew}" icon="#{comm.newClass}"
							actionListener="#{userBean.initAddUser}" update=":user_edit_dialog"
							oncomplete="user_edit_var.show();" disabled="#{!userBean.permission.add}">
							<f:setPropertyActionListener target="#{userBean.model}"
								value="#{comm.m_a}" />
							<f:setPropertyActionListener target="#{userBean.summary}"
								value="添加用户信息：" />
						</p:commandButton>
					</div>
				</f:facet>

				<p:column headerText="编号" style="width: 15%;">#{data.code}</p:column>
				<p:column headerText="名称" style="width: 15%;">#{data.name}</p:column>
				<p:column headerText="性别" style="width: 5%;">#{data.sex}</p:column>
				<p:column headerText="生日" style="width: 10%;">
					#{of:formatDateWithTimezone(data.birth, 'yyyy-MM-dd', 'GMT')}
				</p:column>
				<p:column headerText="移动电话" style="width: 15%;">#{data.mobile}</p:column>
				<p:column headerText="#{msgs.valid}" style="width: 5%;">
					#{data.status == 1 ? msgs.valid_y : msgs.valid_n}
				</p:column>
				<p:column headerText="备注">#{data.note}</p:column>
				<p:column headerText="操作" style="width: 10%">
					<p:commandButton title="#{msgs.btnQuery}" icon="#{comm.queryClass}"
						oncomplete="user_edit_var.show();" update=":user_edit_dialog"
						disabled="#{!userBean.permission.query}">
						<f:setPropertyActionListener target="#{userBean.model}" value="#{comm.m_q}" />
						<f:setPropertyActionListener target="#{userBean.summary}" value="查询用户信息：" />
						<f:setPropertyActionListener target="#{userBean.instance}" value="#{data}"/>
						<f:setPropertyActionListener target="#{userBean.instance.validPassword}"
							value="#{userBean.instance.password}" />
					</p:commandButton>
					
					<p:commandButton title="#{msgs.btnEdit}" icon="#{comm.editClass}"
						oncomplete="user_edit_var.show();" update=":user_edit_dialog"
						disabled="#{!userBean.permission.modify}">
						<f:setPropertyActionListener target="#{userBean.model}" value="#{comm.m_m}" />
						<f:setPropertyActionListener target="#{userBean.summary}" value="编辑用户信息：" />
						<f:setPropertyActionListener target="#{userBean.instance}" value="#{data}"/>
						<f:setPropertyActionListener target="#{userBean.instance.validPassword}"
							value="#{userBean.instance.password}" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</h:form>
	</ui:define>
	<ui:define name="edit_content">
		<ui:include src="/faces/common/user/user_edit.xhtml" />
	</ui:define>
</ui:composition>